package cc.atliberty.creating.builder.carmodel;

import java.util.ArrayList;

/**
 * @Author 元宵
 * @url www.atliberty.cc
 * @Date 2023-10-30 19:17
 * @description:
 */
public abstract class CarModel {
    private ArrayList<String> sequence = new ArrayList<>();
    protected abstract void start();
    protected abstract void stop();
    protected abstract void alarm();
    protected abstract void enginBoom();
    
    final public void run() {
        for (int i = 0; i < this.sequence.size(); i++) {
            String actionName = this.sequence.get(i);
            if (actionName.equalsIgnoreCase("start")){
                this.start();
            } else if (actionName.equalsIgnoreCase("stop")) {
                this.stop();
            } else if (actionName.equalsIgnoreCase("alarm")) {
                this.alarm();
            } else if (actionName.equalsIgnoreCase("enginBoom")) {
                this.enginBoom();
            }
        }
    }
    
    final public void setSequence(ArrayList<String> sequence) {
        this.sequence = sequence;
    }
}
